<template>
    <div>
        <el-dialog :model-value="props.show" @close="close" destroy-on-close>
            <template #header>
                <div>{{props.title}}</div>
            </template>
            <slot></slot>
            <template #footer>
                <span class="dialog-footer">
                    <el-button v-if="props.noPush" type="primary" @click="submit">提交</el-button>
                    <el-button type="danger" @click="close">关闭</el-button>
                </span>
            </template>
        </el-dialog>
    </div>
</template>

<script setup lang='ts'>
import { onMounted } from "vue"
const props = defineProps({
    title: {
        type: String,
        default: "弹出框",
        required: true
    },
    show: {
        type: Boolean,
        default: false,
        required: true
    },
    width: {
        type: String || Boolean,
        default: "200px"
    },
    modal: {
        type: Boolean,
        default: true
    },
    noPush: {
        type: Boolean,
        default: true
    }
})
onMounted(() => {
    console.log("组件加载完成!")
})
const emits = defineEmits(["close", "submit"])
const submit = () => {
    emits("submit")
}
const close = () => {
    emits("close")
}
</script>
<style lang='scss' scoped>
// 去除点击关闭button出现黑色边框
:deep(.el-dialog__headerbtn:focus) {
    outline: none;
}

.dialog-footer {
    display: flex;
    justify-content: center;

    button:first-child {
        margin-right: 10px;
    }
}
</style>